<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<title>遮挡解决穿透</title>

	<style type="text/css">
	body{
		margin: 0;
	}
	.container{
		width: 100%;
		overflow: hidden;
		position: relative;
	}
	.layer-title{
		width: 100%;
		margin: 50px 0;
		text-align: center;
	}
	.layer-action{
		position: absolute;
		bottom: 20px;
		width: 100%;
		text-align: center;
	}
	.btn{
		background-color: #08c;
		border: 0;
		color: #fff;
		height: 30px;
		line-height: 30px;
		width: 100px;
	}

	#underLayer{
		background-color: #eee;
		width: 90%;
		height: 500px;
		line-height: 500px;
		margin: 30px auto 200px;
		text-align: center;
	}

	#popupLayer{
		/*display: none;*/
		background-color: #fff;
		width: 80%;
		height: 200px;
		position: fixed;
		top: 50%;
		left: 50%;
		margin-left: -40%;
		margin-top: -100px;
		z-index: 1;
	}

	#bgMask{
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background-color: rgba(0,0,0,0.6);
	}
	</style>
</head>
<body>
	<div class="container">
		<div id="underLayer">我是底层元素</div>

		<div id="popupLayer">
			<div class="layer-title">弹出框</div>
			<div class="layer-action">
				<button class="btn" id="closePopup">关闭</button>
			</div>
		</div>
	</div>
	<div id="bgMask"></div>


	<script src="js/zepto.min.js"></script>
	<script type="text/javascript">

		// 点击穿透
		var $close = $('#closePopup');
		var $popup = $('#popupLayer');
		var $under = $('#underLayer');
		var $mask = $('#bgMask');

		// 遮挡物
		var $tap = $('<div></div>');
		$tap.css({
			width: '40px',
			height: '40px',
			'border-radius': '20px',
			position: 'absolute',
			opacity: '1'
		});

		$close.on('touchend', function(e){
			$popup.hide();
			$mask.hide();

			var touch = e.changedTouches[0];
			$tap.css({
				top: (touch.pageY-20) + 'px',
				left: (touch.pageX-20) + 'px'
			});

			$('body').append($tap);

			setTimeout(function(){
				$tap.remove();
			}, 400);
		});

		$under.on('click', function(){
			alert('underLayer clicked我是最底层元素');
		});


	</script>
</body>
</html>